import 'package:enterprise_v6_app/app/components/special_operation/custom_select_function.dart';
import 'package:enterprise_v6_app/app/components/toast_widget.dart';
import 'package:enterprise_v6_app/app/core/constans/dict_data_info.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/get_dict_all_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/get_all_cycle_change_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/get_tb_base_measures_task_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/insert_tb_base_measures_task_request_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/double_prevention_page/danger_investigation_page/hazard_investigation_task_management/hazard__task_mget_controller.dart';
import 'package:get/get.dart';

///隐患排查-》任务信息管理-》点击+新增界面
class OnClickAddPageController extends GetxController {
  final String levelMeasuresId = Get.arguments['measuresId'] as String;
  final int level = Get.arguments['level'] as int;
  final bool addEdit = Get.arguments['AddEdit'] as bool;

  /// 外部列表controller
  final hazardInvestigationTaskManagementController = Get.find<HazardInvestigationTaskManagementController>();

  ///新增风险措施任务的实体类
  InsertTbBaseMeasuresTaskRequestEntity insertTbBaseMeasuresTaskRequestEntity = InsertTbBaseMeasuresTaskRequestEntity();

  ///巡检周期hintText内容---
  String hintTextContext1 = '请输入';
  String hintTextContext2 = '请输入';

  String time = '';

  /// 选中的 隐患排查任务管理_管控方式
  GetDictAllEntity? dictEntity1;
  GetDictAllEntity? dictEntity2;
  GetDictAllEntity? dictEntity3;
  GetDictAllEntity? dictEntity4;
  GetDictAllEntity? dictEntity5;
  GetDictAllEntity? dictEntity6;

  /// 获取对应任务类别的所有数据（春夏秋冬）
  List<GetAllCycleChangeEntity>? allCycleChange;

  @override
  void onInit() {
    super.onInit();
    if (addEdit) {
      final String itemId = Get.arguments['itemId'] as String;
      //编辑的界面 需要设置数据 请求
      _getTbBaseMeasuresTask(itemId, addEdit);
    }
  }

  GetTbBaseMeasuresTaskEntity? gData; //需要赋值给另一个实体
  void _getTbBaseMeasuresTask(String itemId, bool addEdit) async {
    final res = await HttpUtil().generateGetRequest<GetTbBaseMeasuresTaskEntity>(
      Interface.getTbBaseMeasuresTask,
      queryParameters: {'id': itemId},
    ).execute();
    res.onSuccess((result) {
      if (result.data != null) {
        gData = result.data!; //缺少数据 workKindCycleChangeList[] 四季
        //id
        insertTbBaseMeasuresTaskRequestEntity.id = gData?.id;
        insertTbBaseMeasuresTaskRequestEntity.troubleshootContent = gData?.troubleshootContent ?? '';
        insertTbBaseMeasuresTaskRequestEntity.controlMeasuresName = gData?.controlMeasuresLabel ?? '';
        insertTbBaseMeasuresTaskRequestEntity.workKindName = gData?.workKindLabel ?? '';
        insertTbBaseMeasuresTaskRequestEntity.instrumentId = gData?.instrumentId ?? '';
        insertTbBaseMeasuresTaskRequestEntity.checkCycleUnitName = gData?.checkCycleUnitLabel ?? '';
        insertTbBaseMeasuresTaskRequestEntity.checkCycleUnit = gData?.checkCycleUnit ?? '';
        insertTbBaseMeasuresTaskRequestEntity.checkCycle = gData?.checkCycle ?? '';
        insertTbBaseMeasuresTaskRequestEntity.workStartTime = gData?.workStartTime ?? '';
        insertTbBaseMeasuresTaskRequestEntity.workEndTime = gData?.workStartTime ?? '';
        insertTbBaseMeasuresTaskRequestEntity.workDayTypeName = gData?.workDayTypeLabel ?? '';
        insertTbBaseMeasuresTaskRequestEntity.workKind = gData?.workKind ?? '';
        //层级id--》措施id  详情的措施id赋值
        insertTbBaseMeasuresTaskRequestEntity.riskMeasureId = gData?.riskMeasureId ?? '';
        insertTbBaseMeasuresTaskRequestEntity.riskMeasureIdName = gData?.riskMeasureName ?? '';
        if (gData?.checkCycleUnitLabel == '小时') {
          insertTbBaseMeasuresTaskRequestEntity.isShowInputAnd = true;
          insertTbBaseMeasuresTaskRequestEntity.isShowTime = true;
        } else {
          insertTbBaseMeasuresTaskRequestEntity.isShowInputAnd = false;
          insertTbBaseMeasuresTaskRequestEntity.isShowTime = false;
        }
        //季节赋值
        if (insertTbBaseMeasuresTaskRequestEntity.workKindName == '季节性排查' || insertTbBaseMeasuresTaskRequestEntity.workKindName == '重点时段及节假日前排查') {
          //季节性排查 和 重点时段及节假日前排查 需要展示隐藏UI
          insertTbBaseMeasuresTaskRequestEntity.isShowSeason = true;

          //先  获取对应任务类别的所有数据 夏
          _getAllCycleChange(gData?.workKind, addEdit: true);
        } else {
          //其余不用
          insertTbBaseMeasuresTaskRequestEntity.isShowSeason = false;
        }
      }
    });
    update();
  }

  /// 类型选择
  void selectHiddenDangerInvestigationTaskControlMeasuresType() async {
    final List<GetDictAllEntity> dictList = await DictDataInfo.getDictionaryDataByTree(dictionaryType: 'hidden_danger_investigation_task_control_measures');
    CustomSelectFunction.selectMultipleBottomSheet<GetDictAllEntity>(
      title: '管控手段',
      dataList: dictList,
      checkedList: [dictEntity1 ?? GetDictAllEntity()],
      isMultiple: false,
      onCallBack: (value) {
        dictEntity1 = value[0];
        insertTbBaseMeasuresTaskRequestEntity.controlMeasures = value[0].getId();
        insertTbBaseMeasuresTaskRequestEntity.controlMeasuresName = value[0].getShowName();
        update();
      },
    );
  }

  /// 类型选择
  void selectHiddenDangerInvestigationTaskWorkKindType() async {
    final List<GetDictAllEntity> dictList = await DictDataInfo.getDictionaryDataByTree(dictionaryType: 'hidden_danger_investigation_task_work_kind');
    CustomSelectFunction.selectMultipleBottomSheet<GetDictAllEntity>(
      title: '任务类别',
      dataList: dictList,
      checkedList: [dictEntity2 ?? GetDictAllEntity()],
      isMultiple: false,
      onCallBack: (value) {
        dictEntity2 = value[0];
        insertTbBaseMeasuresTaskRequestEntity.workKind = value[0].getId();
        insertTbBaseMeasuresTaskRequestEntity.workKindName = value[0].getShowName();
        if (insertTbBaseMeasuresTaskRequestEntity.workKindName == '季节性排查' || insertTbBaseMeasuresTaskRequestEntity.workKindName == '重点时段及节假日前排查') {
          //季节性排查 和 重点时段及节假日前排查 需要展示隐藏UI
          insertTbBaseMeasuresTaskRequestEntity.isShowSeason = true;
          // 获取对应任务类别的所有数据（春夏秋冬）
          _getAllCycleChange(value[0].getId());
        } else {
          //其余不用
          insertTbBaseMeasuresTaskRequestEntity.isShowSeason = false;
          //每次选中都把 巡检周期单位置空
          insertTbBaseMeasuresTaskRequestEntity.checkCycleUnit = '';
          insertTbBaseMeasuresTaskRequestEntity.checkCycleUnitName = '';
        }

        update();
      },
    );
  }

  /// 巡检周期单位
  void selectHiddenDangerInvestigationTaskInspectionCycleUnit() async {
    final List<GetDictAllEntity> dictList =
        await DictDataInfo.getDictionaryDataByTree(dictionaryType: 'hidden_danger_investigation_task_inspection_cycle_unit');
    //请先选中任务类型
    CustomSelectFunction.selectMultipleBottomSheet<GetDictAllEntity>(
      title: '巡检周期单位',
      dataList: dictList,
      checkedList: [dictEntity3 ?? GetDictAllEntity()],
      isMultiple: false,
      onCallBack: (value) {
        dictEntity3 = value[0];
        insertTbBaseMeasuresTaskRequestEntity.checkCycleUnit = value[0].getId();
        insertTbBaseMeasuresTaskRequestEntity.checkCycleUnitName = value[0].getShowName();
        if (insertTbBaseMeasuresTaskRequestEntity.checkCycleUnitName == '小时') {
          if (insertTbBaseMeasuresTaskRequestEntity.workKindName != '日常排查') {
            //如果当前任务类型
            AppToast.showWarning('非日常任务可以选择：天、月、年');
            insertTbBaseMeasuresTaskRequestEntity.checkCycleUnit = '';
            insertTbBaseMeasuresTaskRequestEntity.checkCycleUnitName = '';
            return update();
          }
          //弹出选择框 1-23用户选择；
          insertTbBaseMeasuresTaskRequestEntity.isShowInputAnd = true;
          // insertTbBaseMeasuresTaskRequestEntity.isShowInput = false;

          //工作时段自有在未小时的时候才显示 其余不显示不设置数据
          insertTbBaseMeasuresTaskRequestEntity.isShowTime = true;

          hintTextContext1 = '请输入整数1~23';
          //小时的时候 工作日类型显示 默认每天
          insertTbBaseMeasuresTaskRequestEntity.workDayType = 'cd787615-2413-48a0-9cc9-5e1700261fa9';
          insertTbBaseMeasuresTaskRequestEntity.workDayTypeName = '每天';
        } else {
          if (insertTbBaseMeasuresTaskRequestEntity.workKindName == '日常排查') {
            //如果当前任务类型
            AppToast.showWarning('日常任务只可选择：小时');
            insertTbBaseMeasuresTaskRequestEntity.checkCycleUnit = '';
            insertTbBaseMeasuresTaskRequestEntity.checkCycleUnitName = '';
            return update();
          }

          //其余的就用户输入 整数输入
          insertTbBaseMeasuresTaskRequestEntity.isShowInputAnd = false;
          // insertTbBaseMeasuresTaskRequestEntity.isShowInput = true;
          insertTbBaseMeasuresTaskRequestEntity.isShowTime = false;
          hintTextContext2 = '请输入整数';
          //非小时的时候 工作日类型隐藏 默认每天
          insertTbBaseMeasuresTaskRequestEntity.workDayType = 'cd787615-2413-48a0-9cc9-5e1700261fa9';
          insertTbBaseMeasuresTaskRequestEntity.workDayTypeName = '每天';
        }
        insertTbBaseMeasuresTaskRequestEntity.checkCycle = '';
        //清空实体数据
        // insertTbBaseMeasuresTaskRequestEntity.checkCycle = '23'; //测试用 后面需要选择
        update();
      },
    );
  }

  /// 类型选择2
  void selectInternalHiddenDangerInvestigationTaskInspectionCycleUnit(GetAllCycleChangeEntity item) async {
    final List<GetDictAllEntity> dictList =
        await DictDataInfo.getDictionaryDataByTree(dictionaryType: 'hidden_danger_investigation_task_inspection_cycle_unit');
    CustomSelectFunction.selectMultipleBottomSheet<GetDictAllEntity>(
      title: '巡检周期单位',
      dataList: dictList,
      checkedList: [dictEntity4 ?? GetDictAllEntity()],
      isMultiple: false,
      onCallBack: (value) {
        dictEntity4 = value[0];
        item.checkCycleUnit = value[0].getId();
        item.checkCycleUnitName = value[0].getShowName();
        if (item.checkCycleUnitName == '小时') {
          if (insertTbBaseMeasuresTaskRequestEntity.workKindName != '日常排查') {
            //如果当前任务类型
            AppToast.showWarning('非日常任务可以选择：天、月、年');
            item.checkCycleUnitName = '';
            item.checkCycleUnit = '';
            return update();
          }

          //弹出选择框 1-23用户选择；
          item.isShowInputAnd = true;
          // item.isShowInput = false;

          //工作时段自有在未小时的时候才显示 其余不显示不设置数据
          item.isShowTime = true;
          item.hintTextContext1 = '请输入整数1~23';
        } else {
          //其余的就用户输入 整数输入
          item.isShowInputAnd = false;
          // item.isShowInput = true;
          item.isShowTime = false;
          item.hintTextContext2 = '请输入整数';
        }
        item.checkCycle = '';
        //清空实体数据
        // item.checkCycle = '23'; //测试用 后面需要选择
        update();
      },
    );
  }

  /// 类型选择
  void selectHiddenDangerInvestigationTaskWorkDayType() async {
    final List<GetDictAllEntity> dictList = await DictDataInfo.getDictionaryDataByTree(dictionaryType: 'hidden_danger_investigation_task_work_day_type');
    CustomSelectFunction.selectMultipleBottomSheet<GetDictAllEntity>(
      title: '工作日类型',
      dataList: dictList,
      checkedList: [dictEntity5 ?? GetDictAllEntity()],
      isMultiple: false,
      onCallBack: (value) {
        dictEntity5 = value[0];
        insertTbBaseMeasuresTaskRequestEntity.workDayType = value[0].getId();
        insertTbBaseMeasuresTaskRequestEntity.workDayTypeName = value[0].getShowName();
        update();
      },
    );
  }

  /// 类型选择2
  void selectInternalHiddenDangerInvestigationTaskWorkDayType(GetAllCycleChangeEntity item) async {
    final List<GetDictAllEntity> dictList = await DictDataInfo.getDictionaryDataByTree(dictionaryType: 'hidden_danger_investigation_task_work_day_type');
    CustomSelectFunction.selectMultipleBottomSheet<GetDictAllEntity>(
      title: '工作日类型',
      dataList: dictList,
      checkedList: [dictEntity6 ?? GetDictAllEntity()],
      isMultiple: false,
      onCallBack: (value) {
        dictEntity6 = value[0];
        item.workDayType = value[0].getId();
        item.workDayTypeName = value[0].getShowName();
        update();
      },
    );
  }

  ///作业申请时间选择
  void showDatePicker() {
    CustomSelectFunction.selectDateTime(onCallBack: (String value) {
      time = value;
      update();
    });
  }

  void isBool() {
    update();
  }

  // 新增风险措施任务 bool是否返回
  void insertTbBaseMeasuresTask(bool back) async {
    insertTbBaseMeasuresTaskRequestEntity.workType = 'ad6fdcb8-4fd5-415e-8a2a-af4ba6121694'; //默认写死的日常任务类型（日常任务）
    if (insertTbBaseMeasuresTaskRequestEntity.isShowSeason) {
      //四季bu隐藏的提交
      if (submitAddInside()) {
        final res = await HttpUtil()
            .generatePostRequest(
              addEdit ? Interface.updateTbBaseMeasuresTask : Interface.insertTbBaseMeasuresTask,
              data: insertTbBaseMeasuresTaskRequestEntity.toJson(),
            )
            .execute(isShowLoading: true);
        res.onSuccess((result) {
          if (back) {
            Get.back();
          }
          hazardInvestigationTaskManagementController.globalKey.currentState?.onRefresh();
          //清除数据
          cleanData();
        });
        res.onError((result) {
          AppToast.showError('新增失败');
        });
      }
    } else {
      if (submitAdd()) {
        final res = await HttpUtil()
            .generatePostRequest(
              addEdit ? Interface.updateTbBaseMeasuresTask : Interface.insertTbBaseMeasuresTask,
              data: insertTbBaseMeasuresTaskRequestEntity.toJson(),
            )
            .execute(isShowLoading: true);
        res.onSuccess((result) {
          if (back) {
            Get.back();
          }
          hazardInvestigationTaskManagementController.globalKey.currentState?.onRefresh();
          //清除数据
          cleanData();
        });
        res.onError((result) {
          AppToast.showError('新增失败');
        });
      }
    }
  }

  // 提交时判断 需要塞入选中的四季
  bool submitAddInside() {
    if (insertTbBaseMeasuresTaskRequestEntity.riskMeasureIdName!.isEmpty) {
      AppToast.showWarning('管控措施描述');
      return false;
    }

    if (insertTbBaseMeasuresTaskRequestEntity.troubleshootContent!.isEmpty) {
      AppToast.showWarning('隐患排查内容');
      return false;
    }
    if (insertTbBaseMeasuresTaskRequestEntity.controlMeasuresName!.isEmpty) {
      AppToast.showWarning('管控手段');
      return false;
    }
    if (insertTbBaseMeasuresTaskRequestEntity.workKindName!.isEmpty) {
      AppToast.showWarning('任务类别');
      return false;
    }
    final List<InsertTbBaseMeasuresTaskRequestCheckCycleVoList> checkCycleVoList = [];

    for (int i = 0; i < allCycleChange!.length; i++) {
      if (allCycleChange![i].checkboxSelected) {
        if (allCycleChange![i].checkCycleUnitName!.isEmpty) {
          AppToast.showWarning('巡检周期单位');
          return false;
        }
        if (allCycleChange![i].checkCycle!.isEmpty) {
          AppToast.showWarning('巡检周期');
          return false;
        }
        //isShowTime 工作日类型显示的时候在做判断
        if (allCycleChange![i].isShowTime && allCycleChange![i].workStartTime!.isEmpty) {
          AppToast.showWarning('工作时段');
          return false;
        }
        if (allCycleChange![i].isShowInputAnd && allCycleChange![i].workDayTypeName!.isEmpty) {
          AppToast.showWarning('工作日类型');
          return false;
        }
        //只有选中的才会放入
        final InsertTbBaseMeasuresTaskRequestCheckCycleVoList insertTbBaseMeasuresTaskRequestCheckCycleVoList =
            InsertTbBaseMeasuresTaskRequestCheckCycleVoList();
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.checkCycle = int.parse(allCycleChange![i].checkCycle!);
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.checkCycleUnitName = allCycleChange?[i].checkCycleUnitName;
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.checkCycleUnit = allCycleChange?[i].checkCycleUnit;
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.isShowInputAnd = allCycleChange?[i].isShowInputAnd;
        // insertTbBaseMeasuresTaskRequestCheckCycleVoList.isShowNoInput = allCycleChange?[i].isShowNoInput;
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.isShowTime = allCycleChange?[i].isShowTime;
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.isShowSeason = allCycleChange?[i].isShowSeason;
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.hourStartTime = allCycleChange?[i].workStartTime;
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.hourEndTime = allCycleChange?[i].workEndTime;

        insertTbBaseMeasuresTaskRequestCheckCycleVoList.startTime = allCycleChange?[i].startTime;
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.endTime = allCycleChange?[i].endTime;
        // "attribute": "春",
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.attribute = allCycleChange?[i].attribute;
        //工作日类型
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.executeType = allCycleChange?[i].workDayType;
        //将idx（获取季节接口的实体类id）赋值给请求类insertTbBaseMeasuresTaskRequestCheckCycleVoList中的代表季节的id
        insertTbBaseMeasuresTaskRequestCheckCycleVoList.id = allCycleChange?[i].idX;

        checkCycleVoList.add(insertTbBaseMeasuresTaskRequestCheckCycleVoList);
      }
    }
    insertTbBaseMeasuresTaskRequestEntity.checkCycleVoList = checkCycleVoList;
    if (checkCycleVoList.isEmpty) {
      AppToast.showWarning('请选择按钮');
      return false;
    }
    return true;
  }

  bool submitAdd() {
    if (insertTbBaseMeasuresTaskRequestEntity.riskMeasureIdName!.isEmpty) {
      AppToast.showWarning('管控措施描述');
      return false;
    }
    if (insertTbBaseMeasuresTaskRequestEntity.troubleshootContent!.isEmpty) {
      AppToast.showWarning('隐患排查内容');
      return false;
    }
    if (insertTbBaseMeasuresTaskRequestEntity.controlMeasuresName!.isEmpty) {
      AppToast.showWarning('管控手段');
      return false;
    }
    if (insertTbBaseMeasuresTaskRequestEntity.workKindName!.isEmpty) {
      AppToast.showWarning('任务类别');
      return false;
    }
    if (insertTbBaseMeasuresTaskRequestEntity.checkCycleUnitName!.isEmpty) {
      AppToast.showWarning('巡检周期单位');
      return false;
    }
    if (insertTbBaseMeasuresTaskRequestEntity.checkCycle!.isEmpty) {
      AppToast.showWarning('巡检周期');
      return false;
    }
    //isShowTime 工作日类型显示的时候在做判断
    if (insertTbBaseMeasuresTaskRequestEntity.isShowTime && insertTbBaseMeasuresTaskRequestEntity.workStartTime!.isEmpty) {
      AppToast.showWarning('工作时段');
      return false;
    }
    //当巡检周期为小时才判断必填 其余的不判断必填
    if (insertTbBaseMeasuresTaskRequestEntity.isShowInputAnd && insertTbBaseMeasuresTaskRequestEntity.workDayTypeName!.isEmpty) {
      AppToast.showWarning('工作日类型');
      return false;
    }
    return true;
  }

  void cleanData() {
    insertTbBaseMeasuresTaskRequestEntity.riskMeasureIdName = '';
    insertTbBaseMeasuresTaskRequestEntity.troubleshootContent = '';
    insertTbBaseMeasuresTaskRequestEntity.controlMeasuresName = '';
    insertTbBaseMeasuresTaskRequestEntity.workKindName = '';
    insertTbBaseMeasuresTaskRequestEntity.instrumentId = '';
    insertTbBaseMeasuresTaskRequestEntity.checkCycleUnitName = '';
    insertTbBaseMeasuresTaskRequestEntity.checkCycle = '';
    insertTbBaseMeasuresTaskRequestEntity.workStartTime = '';
    insertTbBaseMeasuresTaskRequestEntity.workEndTime = '';
    insertTbBaseMeasuresTaskRequestEntity.workDayTypeName = '';
    //编辑和这个请求节点不为null
    if (insertTbBaseMeasuresTaskRequestEntity.isShowSeason && insertTbBaseMeasuresTaskRequestEntity.checkCycleVoList != null) {
      //四季不隐藏清空数据
      //季节里的数据
      for (int i = 0; i < insertTbBaseMeasuresTaskRequestEntity.checkCycleVoList!.length; i++) {
        insertTbBaseMeasuresTaskRequestEntity.checkCycleVoList?[i].checkCycleUnitName = '';
        insertTbBaseMeasuresTaskRequestEntity.checkCycleVoList?[i].checkCycle = 0;
        insertTbBaseMeasuresTaskRequestEntity.checkCycleVoList?[i].hourStartTime = '';
        insertTbBaseMeasuresTaskRequestEntity.checkCycleVoList?[i].hourEndTime = '';
        insertTbBaseMeasuresTaskRequestEntity.checkCycleVoList?[i].startTime = '';
        insertTbBaseMeasuresTaskRequestEntity.checkCycleVoList?[i].endTime = '';
      }
      for (int i = 0; i < allCycleChange!.length; i++) {
        if (allCycleChange![i].checkboxSelected) {
          allCycleChange![i].checkCycleUnitName = '';
          allCycleChange![i].checkCycle = '';
          //isShowTime 工作日类型显示的时候在做判断
          allCycleChange![i].isShowTime = false;
          allCycleChange![i].workStartTime = '';
          allCycleChange![i].workDayTypeName = '';
          allCycleChange![i].checkboxSelected = false;
        }
      }
    }
    update();
  }

  void _getAllCycleChange(String? id, {bool addEdit = false}) async {
    final res = await HttpUtil().generateGetRequest<List<GetAllCycleChangeEntity>>(Interface.getAllCycleChange, queryParameters: {'id': id}).execute();
    res.onSuccess((result) {
      if (result.data != null) {
        if (addEdit) {
          //编辑操作
          //显示季节
          for (int i = 0; i < result.data!.length; i++) {
            //循环它找到对应的季节 设置选中按钮
            for (int j = 0; j < gData!.workKindCycleChangeList!.length; j++) {
              if (result.data?[i].attribute == gData!.workKindCycleChangeList![j].attribute) {
                //相等赋值  设置按钮
                result.data?[i].checkCycle = gData!.workKindCycleChangeList![j].checkCycle ?? '';
                result.data?[i].checkCycleUnitName = gData!.workKindCycleChangeList![j].checkCycleUnitLabel ?? '';
                result.data?[i].checkCycleUnit = gData!.workKindCycleChangeList![j].checkCycleUnit ?? '';
                if (gData!.workKindCycleChangeList![j].checkCycleUnitLabel == '小时') {
                  //弹出选择框 1-23用户选择；
                  result.data?[i].isShowInputAnd = true;
                  // result.data?[i].isShowInput = false;
                  //工作时段自有在未小时的时候才显示 其余不显示不设置数据
                  result.data?[i].isShowTime = true;
                } else {
                  //其余的就用户输入 整数输入
                  result.data?[i].isShowInputAnd = false;
                  // result.data?[i].isShowInput = true;
                  result.data?[i].isShowTime = false;
                }
                // result.data?[i].isShowSeason =Gdata!.workKindCycleChangeList![j].isShowSeason;
                result.data?[i].workStartTime = gData!.workKindCycleChangeList![j].hourStartTime ?? '';
                result.data?[i].workEndTime = gData!.workKindCycleChangeList![j].hourEndTime ?? '';
                result.data?[i].startTime = gData!.workKindCycleChangeList![j].startTime ?? '';
                result.data?[i].endTime = gData!.workKindCycleChangeList![j].endTime ?? '';
                //工作日类型 	String? workDayTypeName='';
                result.data?[i].workDayType = gData!.workKindCycleChangeList![j].executeType ?? '';
                result.data?[i].workDayTypeName = gData!.workKindCycleChangeList![j].executeTypeLabel ?? '';
                //按钮选中
                result.data?[i].checkboxSelected = true;
                //详情id赋值给idx idx还要给insertTbBaseMeasuresTaskRequestEntity。。id
                result.data?[i].idX = gData!.workKindCycleChangeList![j].id;
              }
            }
          }
          // 获取对应任务类别的所有数据（春夏秋冬）
          // _getAllCycleChange(value[0].getId());不去获取 后台返回了
          if (gData?.workKindCycleChangeList != null) {
          } else {
            //隐藏季节
            insertTbBaseMeasuresTaskRequestEntity.isShowSeason = false;
          }
        }
        allCycleChange = result.data!;
        update();
      }
    });
  }

  void isUpdate() {
    update();
  }
}
